home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / Snippets / Toolbox / WaveTable Sounds / SquareWaveSynthPlay.c next >
Encoding:
C/C++ Source or Header  |  1992-10-13  |  1.5 KB  |  87 lines  |  [TEXT/MPS ]

  1. /*
  2.     SquareWaveSynthPlay 12:29:17 PM  10/13/92 •  Brigham Stevens
  3.     
  4.     Plays a sound using the squareWaveSynth.
  5.  
  6.     Sets the timbre with timbreCmd
  7.     Starts playing witht the freqCmd
  8.     
  9.     InitDialogs is called only to install crash handler in case
  10.     no Debugger exists.
  11. ##
  12. ##    copy to worksheet, select, press enter
  13. ###    
  14. ##    BuildCommands:
  15. ##
  16.     C -r  SquareWaveSynthPlay.c
  17.     Link -t APPL -c '????' SquareWaveSynthPlay.c.o ∂
  18.         "{Libraries}"Runtime.o ∂
  19.         "{Libraries}"Interface.o ∂
  20.         -o SquareWaveSynthPlay
  21.     SquareWaveSynthPlay
  22. */
  23.  
  24. #include <Dialogs.h>
  25. #include <Sound.h>
  26.  
  27. void SquareWaveSynthPlay()
  28. {
  29.     SndChannelPtr    chan;
  30.     SndCommand        mycmd;
  31.     long            count;
  32.     short            change = 0;
  33.     short            err;
  34.     
  35.     
  36.     /* Allocate a channel tied to the squareWaveSynth */
  37.     chan = nil;
  38.     err = SndNewChannel (&chan, squareWaveSynth, 0, nil);
  39.     if (err) {
  40.         DebugStr("\p error SndNewChannel [2]");
  41.         goto bail;
  42.     }
  43.     
  44.     mycmd.cmd = freqCmd;
  45.     mycmd.param1 = 0;
  46.     mycmd.param2 = 50;
  47.     
  48.     err = SndDoImmediate (chan, &mycmd);
  49.     if (err) {
  50.         DebugStr("\p error SndDoImmediate [3]");
  51.         goto bail;
  52.     }
  53.         
  54.     mycmd.cmd = timbreCmd;
  55.     mycmd.param1 = 0;
  56.     mycmd.param2 = 86;
  57.     
  58.     err = SndDoImmediate (chan, &mycmd);
  59.     if (err) {
  60.         DebugStr("\p error SndDoImmediate [3]");
  61.         goto bail;
  62.     }
  63.     
  64.     Delay (180, &count);
  65.         
  66.     err = SndDisposeChannel (chan,false);
  67.     if (err) {
  68.         DebugStr("\p error SndDisposeChannel [2]");
  69.         goto bail;
  70.     }
  71. bail:
  72.     return;
  73. }
  74.  
  75.  
  76. pascal Panic()
  77. {
  78.     /* if no debugger installed, this */
  79.     /* may save you from re-booting */
  80.     ExitToShell();
  81. }
  82.  
  83. main()
  84. {
  85.     InitDialogs((ResumeProcPtr)Panic);
  86.     SquareWaveSynthPlay();
  87. }